const dgram = require('dgram');
const client = dgram.createSocket('udp4');

client.on('close', () => {
    console.log('socket已关闭');
});

client.on('error', (err) => {
    console.log(err);
});
client.on('message', (msg, rInfo) => {
    if (msg == 'exit') {
        client.close();
    }
    console.log(`receive message from ${rInfo.address}:${rInfo.port}`);
});

client.send(`hello udp`, 8080, '127.0.0.1');
